<extend name="Layout:layout_list" />
<block name="head_after_block">    
    <link href="__THEME__Css/frm-edit-page.css" rel="stylesheet" type="text/css"/>
</block>
<block name="body_before_block">
    <script src="__THEME__Plugin/ajax_load_options.min.js" type="text/javascript"></script>
</block>
<block name="body_content_block">
    <form action="{:AddonU('SMS/sms_import_save')}" method="post" enctype="multipart/form-data">
        <div class="radio-button-set">
            <input type="radio" name="source" checked="checked" value="import" />导入
            <input type="radio" name="source" value='add' />添加
        </div>
        <table>
            <if condition="$isSuperAdmin">
                <tr><th>租户ID：</th><td><select name="siteID" title="请选择租户" data-url="{:AddonU('Admin/get_admin_json')}" data-value="{$data.siteID}"></select></td></tr>
                <else/>
                <tr style="display: none;"><input type="hidden" name="siteID" value="{$loginData.siteID}"/></td></tr>
            </if>
            <tr>
                <th>短信服务器：</th><td>
                <select name="serverID"  title="请选择短信服务器" required data-url="{:AddonU('SMS/get_server_json')}" data-value="{$data.serverID}"></select>
            </td></tr>
            <tr>
                <th>号码文件：</th><td>
                <input type="file" name="xlsFile" title="请选择号码文件!" />
                <span style="color:#F00;">(号码文件名不能含有中文,文件格式可以是Excel或txt,如果是Excel,内容列格式：号码,如不符合格式请先整理后导入!)</span>
            </td></tr>
            <tr style="display: none;">
                <th>手机号码：</th><td>
                <input type="text" class="easyui-textbox" name="phoneNumber" title="请填写手机号码!" />
            </td></tr>
            <tr>
                <th>短信内容：</th><td>
                <textarea cols="60" rows="3" name="message" placeholder="短信内容">{$data.message}</textarea>
                <span id="char-count"></span>
            </td></tr>
            <tr>
                <th>短信签名：</th><td>
                <input type="text" class="easyui-textbox" name="sign" placeholder="请输入短信签名" value="{$data.sign}" />
            </td></tr>
            <tr>
                <th>&nbsp;</th><td>
                <input type="submit" value="发送" class="button" /><input type="reset" value="重置" class="button" /></td></tr>
        </table>
        <input type='hidden' value='{$data.id}' name='id' />
    </form>
    <table class="table-list">
        <thead>
	    <tr><th>序号</th><if condition="$isSuperAdmin"><th>租户ID</th></if><th>短信服务器</th><th>号码</th><th>来源</th><th>添加日期</th></tr>
        </thead>
        <tbody>
        <foreach name="list" item="vo" >
            <tr data-key="{$vo.id}"><td title="{$vo.id},{$vo.taskID},{$vo.siteID}">{$key}</td><if condition="$isSuperAdmin"><td>{$vo.siteID}</td></if><td>{$vo.serverName}</td><td>{$vo.phoneNumber}</td><td>{$vo.source|sofn_get_state_text='record-source',###}</td><td>{$vo.createdTime}</td></tr>
        </foreach>
        </tbody>
    </table>
</block>
<block name="body_after_block">
    <script>
    ajax_load_options({selector:'select[name="siteID"]', def_option: '选择租户', func:afterSiteID});
    afterSiteID();
    function afterSiteID() {
        var val = $('[name="siteID"]').val();
        ajax_load_options({selector:'select[name="serverID"]',queryParams:{siteID:val},def_option:'选择短信服务器'});
    }
    $('select[name="siteID"]').change(function () {
        afterSiteID();
    })
    $('input[name="source"]').click(function () {
        if ($(this).val() == 'import') {
            $('input[name="xlsFile"]').parent().show().next().hide();
        } else {
            $('input[name="phoneNumber"]').parent().show().prev().hide();
        }
    })
    $('textarea[name="message"],input[name="sign"]').bind('blur keypress change', function () {
        var i = $('textarea[name="message"]').val().length + $('input[name="sign"]').val().length;
        $('#char-count').text(i);
    })
</script>
</block>